<?php
/**
 * Created by PhpStorm.
 * User: jksen
 * Date: 2018/1/18
 * Time: 上午11:37
 */

namespace app\admin\controller\v1;

use \app\common\Validate\WidgetVailidate;
use Think\Exception;
/**
 * @title 控件类接口V1
 * @description 接口说明
 *
 * @header name:copyright require:1 default:v1 desc:版本号(全局)
 */
class Widget
{

    public function addWidget()
    {
        $model = model('app\common\model\Widget');
        $model->widget_name = '请填入您的寄件地址';
        $model->field_name = 'shipper_address';
        $model->field_length = '120';
        $model->field_type = 'input';
        $model->tip_text = '请填入您的寄件地址';
        $model->is_required = true;
        $model->is_empty = false;

        $validate = validate('WidgetVailidate');
        if ($validate->scene('add')->check($model)) {
            $model->save();
            return $model->getLastInsID();
        }
        pr($validate->getError());
    }
}